#include <iostream>
using namespace std;

string s;

int main()
{
    cin >> s;
    int i = 0;
    int n = s.size();
    int len = 0x3f3f3f3f;
    while (i < n)
    {
        int left = i, right = i;
        while (left >= 0 && right < n && s[left] == s[right])
        {
            left--;
            right++;
            if (right - left - 1 == 3)
            {
                len = right - left - 1;
                break;
            }
        }

        left = i, right = i + 1;
        while (left >= 0 && right < n && s[left] == s[right])
        {
            left--;
            right++;
            if (right - left - 1 == 2)
            {
                len = right - left - 1;
                break;
            }
        }

        i++;
    }
    if (len == 0x3f3f3f3f) cout << "-1" << endl;
    else cout << len << endl;
    return 0;
}

#include <iostream>
using namespace std;
const int N = 1e6 + 10;
int n;
int arr[N];
int f[N], g[N];
int ret;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 1; i <= n; i++)
    {
        f[i] = g[i - 1] + arr[i - 1];
        g[i] = max(g[i - 1], f[i - 1]);
        ret = max(ret, max(f[i], g[i]));
    }
    cout << ret << endl;
    return 0;
}


#include <iostream>
#include<algorithm>
using namespace std;
const int N = 1e6 + 10;
int n, p;
int a[N];
int main()
{
    cin >> n >> p;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    p *= 2;
    int left = 0, right = 0, ret = 0;
    while (right < n)
    {
        while (a[right] - a[left] > p)
        {
            left++;
        }
        ret = max(ret, right - left + 1);
        right++;
    }
    cout << ret << endl;
    return 0;
}